function main() {
    (function () {
        'use strict';
        // jQuery to collapse the navbar on scroll
        $(window).scroll(function () {
            if ($(".navbar").offset().top > 50) {
                $(".navbar-fixed-top").addClass("top-nav-collapse");
            } else {
                $(".navbar-fixed-top").removeClass("top-nav-collapse");
            }
        });


        // Testimonial Slider
        $('a.page-scroll').click(function () {
            if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
                var target = $(this.hash);
                target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
                if (target.length) {
                    //点击导航链接之后，把导航选项折叠起来
                    $(".navbar-main-collapse").collapse('hide');

                    $('html,body').animate({
                        scrollTop: target.offset().top - 40
                    }, 900);


                    return false;
                }
            }
        });

        /*====================================
         Slider
        ======================================*/
        $(document).ready(function () {
            $("#testimonial").owlCarousel({
                items: 1, //在屏幕中可见的旋转木马项
                loop: true, //是否无限循环，会复制第一项和最后一项来制作无限循环的错觉
                margin: 10, //图片间距10px
                autoplay: true, //旋转木马是否自动播放
                autoplayTimeout: 3000, //旋转木马自动播放的时间间隔
                autoplayHoverPause: true, //是否在鼠标滑过时停止自动播放
                dots: true //显示圆点导航按钮
            });

        });

        /*=====================================
         Portfolio Isotope Filter
         ======================================*/
        $(window).load(function () {
            var $container = $('.portfolio-items');
            $container.isotope(); //初始化

            $('.cat a').click(function () {
                $('.cat .active').removeClass('active');
                $(this).addClass('active');

                var selector = $(this).attr('data-filter');
                $container.isotope({
                    filter: selector
                });
                return false;
            });

        });

        /*====================================
           counterUp
         ======================================*/
        $(document).ready(function ($) {
            if ($("span.count").length > 0) {
                $('span.count').counterUp({
                    delay: 10, // the delay time in ms
                    time: 1000 // the speed time in ms
                });
            }
        });

    }());
}
main();